package androidx.fragment.app;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.content.IntentSender;
import android.content.IntentSender.SendIntentException;
import android.content.res.Configuration;
import android.os.Bundle;
import android.os.Parcelable;
import android.util.AttributeSet;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import androidx.activity.ComponentActivity;
import androidx.activity.OnBackPressedDispatcher;
import androidx.annotation.CallSuper;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import java.io.FileDescriptor;
import java.io.PrintWriter;
import o.ai;
import o.dz;
import o.fe;
import o.fe.d;
import o.fe.e;
import o.FragmentManager;
import o.jv;
import o.jw;
import o.kp;
import o.kx;
import o.ld;
import o.lg;
import o.lh;

public class FragmentActivity extends ComponentActivity implements d, e {
    boolean ʻ;
    int ʼ;
    dz<String> ʽ;
    boolean ˊ = true;
    final jw ˋ = jw.ॱ(new c(this));
    final kx ˎ = new kx(this);
    boolean ˏ;
    boolean ॱ;
    boolean ॱॱ;
    boolean ᐝ;

    class c extends jv<FragmentActivity> implements lg, ai {
        final /* synthetic */ FragmentActivity ॱ;

        public /* synthetic */ Object ʻ() {
            return ˏ();
        }

        public c(FragmentActivity fragmentActivity) {
            this.ॱ = fragmentActivity;
            super(fragmentActivity);
        }

        @NonNull
        public kp ac_() {
            return this.ॱ.ˎ;
        }

        @NonNull
        public lh U_() {
            return this.ॱ.U_();
        }

        @NonNull
        public OnBackPressedDispatcher ॱ() {
            return this.ॱ.ॱ();
        }

        public void ˋ(@NonNull String str, @Nullable FileDescriptor fileDescriptor, @NonNull PrintWriter printWriter, @Nullable String[] strArr) {
            this.ॱ.dump(str, fileDescriptor, printWriter, strArr);
        }

        public boolean ˋ(@NonNull Fragment fragment) {
            return !this.ॱ.isFinishing();
        }

        @NonNull
        public LayoutInflater ˎ() {
            return this.ॱ.getLayoutInflater().cloneInContext(this.ॱ);
        }

        public FragmentActivity ˏ() {
            return this.ॱ;
        }

        public void ॱॱ() {
            this.ॱ.ʽ();
        }

        public void ˋ(@NonNull Fragment fragment, Intent intent, int i, @Nullable Bundle bundle) {
            this.ॱ.ॱ(fragment, intent, i, bundle);
        }

        public boolean ᐝ() {
            return this.ॱ.getWindow() != null;
        }

        public int ʼ() {
            Window window = this.ॱ.getWindow();
            return window == null ? 0 : window.getAttributes().windowAnimations;
        }

        public void ॱ(@NonNull Fragment fragment) {
            this.ॱ.ˊ(fragment);
        }

        @Nullable
        public View ˊ(int i) {
            return this.ॱ.findViewById(i);
        }

        public boolean d_() {
            Window window = this.ॱ.getWindow();
            return (window == null || window.peekDecorView() == null) ? false : true;
        }
    }

    @CallSuper
    protected void onActivityResult(int i, int i2, @Nullable Intent intent) {
        this.ˋ.ˋ();
        int i3 = i >> 16;
        if (i3 != 0) {
            int i4 = i3 - 1;
            String str = (String) this.ʽ.ˊ(i4);
            this.ʽ.ॱ(i4);
            if (str == null) {
                Log.w("FragmentActivity", "Activity result delivered for unknown Fragment.");
                return;
            }
            Fragment ˊ = this.ˋ.ˊ(str);
            if (ˊ == null) {
                Log.w("FragmentActivity", "Activity result no fragment exists for who: " + str);
                return;
            } else {
                ˊ.ॱ(65535 & i, i2, intent);
                return;
            }
        }
        o.fe.c ˊ2 = fe.ˊ();
        if (ˊ2 == null || !ˊ2.ॱ(this, i, i2, intent)) {
            super.onActivityResult(i, i2, intent);
        }
    }

    @CallSuper
    public void onMultiWindowModeChanged(boolean z) {
        this.ˋ.ॱ(z);
    }

    @CallSuper
    public void onPictureInPictureModeChanged(boolean z) {
        this.ˋ.ˎ(z);
    }

    public void onConfigurationChanged(@NonNull Configuration configuration) {
        super.onConfigurationChanged(configuration);
        this.ˋ.ˋ();
        this.ˋ.ˏ(configuration);
    }

    public void onCreate(@Nullable Bundle bundle) {
        this.ˋ.ˎ(null);
        if (bundle != null) {
            this.ˋ.ˏ(bundle.getParcelable("android:support:fragments"));
            if (bundle.containsKey("android:support:next_request_index")) {
                this.ʼ = bundle.getInt("android:support:next_request_index");
                int[] intArray = bundle.getIntArray("android:support:request_indicies");
                String[] stringArray = bundle.getStringArray("android:support:request_fragment_who");
                if (intArray == null || stringArray == null || intArray.length != stringArray.length) {
                    Log.w("FragmentActivity", "Invalid requestCode mapping in savedInstanceState.");
                } else {
                    this.ʽ = new dz(intArray.length);
                    for (int i = 0; i < intArray.length; i++) {
                        this.ʽ.ˋ(intArray[i], stringArray[i]);
                    }
                }
            }
        }
        if (this.ʽ == null) {
            this.ʽ = new dz();
            this.ʼ = 0;
        }
        super.onCreate(bundle);
        this.ˎ.ˊ(kp.e.ON_CREATE);
        this.ˋ.ˏ();
    }

    public boolean onCreatePanelMenu(int i, @NonNull Menu menu) {
        if (i == 0) {
            return super.onCreatePanelMenu(i, menu) | this.ˋ.ˋ(menu, getMenuInflater());
        }
        return super.onCreatePanelMenu(i, menu);
    }

    @Nullable
    public View onCreateView(@Nullable View view, @NonNull String str, @NonNull Context context, @NonNull AttributeSet attributeSet) {
        View ˊ = ˊ(view, str, context, attributeSet);
        if (ˊ == null) {
            return super.onCreateView(view, str, context, attributeSet);
        }
        return ˊ;
    }

    @Nullable
    public View onCreateView(@NonNull String str, @NonNull Context context, @NonNull AttributeSet attributeSet) {
        View ˊ = ˊ(null, str, context, attributeSet);
        if (ˊ == null) {
            return super.onCreateView(str, context, attributeSet);
        }
        return ˊ;
    }

    @Nullable
    final View ˊ(@Nullable View view, @NonNull String str, @NonNull Context context, @NonNull AttributeSet attributeSet) {
        return this.ˋ.ˋ(view, str, context, attributeSet);
    }

    protected void onDestroy() {
        super.onDestroy();
        this.ˋ.ॱॱ();
        this.ˎ.ˊ(kp.e.ON_DESTROY);
    }

    public void onLowMemory() {
        super.onLowMemory();
        this.ˋ.ͺ();
    }

    public boolean onMenuItemSelected(int i, @NonNull MenuItem menuItem) {
        if (super.onMenuItemSelected(i, menuItem)) {
            return true;
        }
        switch (i) {
            case 0:
                return this.ˋ.ˏ(menuItem);
            case 6:
                return this.ˋ.ˋ(menuItem);
            default:
                return false;
        }
    }

    public void onPanelClosed(int i, @NonNull Menu menu) {
        switch (i) {
            case 0:
                this.ˋ.ˊ(menu);
                break;
        }
        super.onPanelClosed(i, menu);
    }

    protected void onPause() {
        super.onPause();
        this.ˏ = false;
        this.ˋ.ʽ();
        this.ˎ.ˊ(kp.e.ON_PAUSE);
    }

    @CallSuper
    protected void onNewIntent(@SuppressLint({"UnknownNullness"}) Intent intent) {
        super.onNewIntent(intent);
        this.ˋ.ˋ();
    }

    public void onStateNotSaved() {
        this.ˋ.ˋ();
    }

    protected void onResume() {
        super.onResume();
        this.ˏ = true;
        this.ˋ.ˋ();
        this.ˋ.ॱˊ();
    }

    protected void onPostResume() {
        super.onPostResume();
        ˋॱ();
    }

    protected void ˋॱ() {
        this.ˎ.ˊ(kp.e.ON_RESUME);
        this.ˋ.ʻ();
    }

    public boolean onPreparePanel(int i, @Nullable View view, @NonNull Menu menu) {
        if (i == 0) {
            return ˊ(view, menu) | this.ˋ.ˎ(menu);
        }
        return super.onPreparePanel(i, view, menu);
    }

    @Deprecated
    @RestrictTo({RestrictTo.d.ॱ})
    protected boolean ˊ(@Nullable View view, @NonNull Menu menu) {
        return super.onPreparePanel(0, view, menu);
    }

    public void onSaveInstanceState(@NonNull Bundle bundle) {
        super.onSaveInstanceState(bundle);
        ॱॱ();
        this.ˎ.ˊ(kp.e.ON_STOP);
        Parcelable ˎ = this.ˋ.ˎ();
        if (ˎ != null) {
            bundle.putParcelable("android:support:fragments", ˎ);
        }
        if (this.ʽ.ˋ() > 0) {
            bundle.putInt("android:support:next_request_index", this.ʼ);
            int[] iArr = new int[this.ʽ.ˋ()];
            String[] strArr = new String[this.ʽ.ˋ()];
            for (int i = 0; i < this.ʽ.ˋ(); i++) {
                iArr[i] = this.ʽ.ˋ(i);
                strArr[i] = (String) this.ʽ.ˎ(i);
            }
            bundle.putIntArray("android:support:request_indicies", iArr);
            bundle.putStringArray("android:support:request_fragment_who", strArr);
        }
    }

    protected void onStart() {
        super.onStart();
        this.ˊ = false;
        if (!this.ॱ) {
            this.ॱ = true;
            this.ˋ.ॱ();
        }
        this.ˋ.ˋ();
        this.ˋ.ॱˊ();
        this.ˎ.ˊ(kp.e.ON_START);
        this.ˋ.ᐝ();
    }

    protected void onStop() {
        super.onStop();
        this.ˊ = true;
        ॱॱ();
        this.ˋ.ʼ();
        this.ˎ.ˊ(kp.e.ON_STOP);
    }

    @Deprecated
    public void ʽ() {
        invalidateOptionsMenu();
    }

    public void dump(@NonNull String str, @Nullable FileDescriptor fileDescriptor, @NonNull PrintWriter printWriter, @Nullable String[] strArr) {
        super.dump(str, fileDescriptor, printWriter, strArr);
        printWriter.print(str);
        printWriter.print("Local FragmentActivity ");
        printWriter.print(Integer.toHexString(System.identityHashCode(this)));
        printWriter.println(" State:");
        String str2 = str + "  ";
        printWriter.print(str2);
        printWriter.print("mCreated=");
        printWriter.print(this.ॱ);
        printWriter.print(" mResumed=");
        printWriter.print(this.ˏ);
        printWriter.print(" mStopped=");
        printWriter.print(this.ˊ);
        if (getApplication() != null) {
            ld.ˎ(this).ˎ(str2, fileDescriptor, printWriter, strArr);
        }
        this.ˋ.ˊ().ˎ(str, fileDescriptor, printWriter, strArr);
    }

    public void ˊ(@NonNull Fragment fragment) {
    }

    @NonNull
    public FragmentManager ˏॱ() {
        return this.ˋ.ˊ();
    }

    public void startActivityForResult(@SuppressLint({"UnknownNullness"}) Intent intent, int i) {
        if (!(this.ॱॱ || i == -1)) {
            ˋ(i);
        }
        super.startActivityForResult(intent, i);
    }

    public void startActivityForResult(@SuppressLint({"UnknownNullness"}) Intent intent, int i, @Nullable Bundle bundle) {
        if (!(this.ॱॱ || i == -1)) {
            ˋ(i);
        }
        super.startActivityForResult(intent, i, bundle);
    }

    public void startIntentSenderForResult(@SuppressLint({"UnknownNullness"}) IntentSender intentSender, int i, @Nullable Intent intent, int i2, int i3, int i4) throws SendIntentException {
        if (!(this.ᐝ || i == -1)) {
            ˋ(i);
        }
        super.startIntentSenderForResult(intentSender, i, intent, i2, i3, i4);
    }

    public void startIntentSenderForResult(@SuppressLint({"UnknownNullness"}) IntentSender intentSender, int i, @Nullable Intent intent, int i2, int i3, int i4, @Nullable Bundle bundle) throws SendIntentException {
        if (!(this.ᐝ || i == -1)) {
            ˋ(i);
        }
        super.startIntentSenderForResult(intentSender, i, intent, i2, i3, i4, bundle);
    }

    static void ˋ(int i) {
        if ((-65536 & i) != 0) {
            throw new IllegalArgumentException("Can only use lower 16 bits for requestCode");
        }
    }

    public final void c_(int i) {
        if (!this.ʻ && i != -1) {
            ˋ(i);
        }
    }

    public void onRequestPermissionsResult(int i, @NonNull String[] strArr, @NonNull int[] iArr) {
        this.ˋ.ˋ();
        int i2 = (i >> 16) & 65535;
        if (i2 != 0) {
            int i3 = i2 - 1;
            String str = (String) this.ʽ.ˊ(i3);
            this.ʽ.ॱ(i3);
            if (str == null) {
                Log.w("FragmentActivity", "Activity result delivered for unknown Fragment.");
                return;
            }
            Fragment ˊ = this.ˋ.ˊ(str);
            if (ˊ == null) {
                Log.w("FragmentActivity", "Activity result no fragment exists for who: " + str);
            } else {
                ˊ.ॱ(i & 65535, strArr, iArr);
            }
        }
    }

    public void ॱ(@NonNull Fragment fragment, @SuppressLint({"UnknownNullness"}) Intent intent, int i, @Nullable Bundle bundle) {
        this.ॱॱ = true;
        if (i == -1) {
            try {
                fe.ॱ(this, intent, -1, bundle);
            } finally {
                this.ॱॱ = false;
            }
        } else {
            ˋ(i);
            fe.ॱ(this, intent, ((ˋ(fragment) + 1) << 16) + (65535 & i), bundle);
            this.ॱॱ = false;
        }
    }

    private int ˋ(@NonNull Fragment fragment) {
        if (this.ʽ.ˋ() >= 65534) {
            throw new IllegalStateException("Too many pending Fragment activity results.");
        }
        while (this.ʽ.ˏ(this.ʼ) >= 0) {
            this.ʼ = (this.ʼ + 1) % 65534;
        }
        int i = this.ʼ;
        this.ʽ.ˋ(i, fragment.ˊॱ);
        this.ʼ = (this.ʼ + 1) % 65534;
        return i;
    }

    private void ॱॱ() {
        do {
        } while (ˋ(ˏॱ(), o.kp.c.CREATED));
    }

    private static boolean ˋ(FragmentManager juVar, o.kp.c cVar) {
        boolean z = false;
        for (Fragment fragment : juVar.ˏ()) {
            if (fragment != null) {
                boolean ˋ;
                if (fragment.ac_().ˋ().ˏ(o.kp.c.STARTED)) {
                    fragment.ꓸ.ˊ(cVar);
                    z = true;
                }
                if (fragment.ʻॱ() != null) {
                    ˋ = ˋ(fragment.ʽॱ(), cVar) | z;
                } else {
                    ˋ = z;
                }
                z = ˋ;
            }
        }
        return z;
    }
}
